package com.xuetang9.t9.hotel.services.impl;

import com.xuetang9.t9.hotel.beans.RoomState;
import com.xuetang9.t9.hotel.mapper.IRoomInfoMapper;
import com.xuetang9.t9.hotel.mapper.IRoomStateMapper;
import com.xuetang9.t9.hotel.services.IRoomStateService;
import com.xuetang9.t9.hotel.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 房间状态业务层
 */
@Service
public class RoomStateServiceImpl implements IRoomStateService {
    @Autowired
    private IRoomStateMapper roomStateMapper;

    @Autowired
    private IRoomInfoMapper roomInfoMapper;


    @Override
    public boolean save(RoomState state) {
        return roomStateMapper.insert(state) > 0;
    }

    @Override
    public boolean remove(Integer id) {
        roomInfoMapper.delete(roomStateMapper.selectById(id).getStateId());
        return roomStateMapper.delete(id) > 0;
    }

    @Override
    public boolean alter(RoomState state) {
        return roomStateMapper.update(state) > 0;
    }

    @Override
    public ResponseResult findByAll() {
        return ResponseResult.okResult(roomStateMapper.selectByAll());
    }

    @Override
    public ResponseResult findByStateAll() {
        return ResponseResult.okResult(roomStateMapper.selectByStateAll());
    }

    @Override
    public RoomState findById(Integer id) {
        return roomStateMapper.selectById(id);
    }
}
